Python How-To by Yong Cui

Python How-To by Yong Cui
Author: Yong Cui [Yong Cui]
Language: eng
Format: epub, pdf
Publisher: Manning Publications Co.
Published: 2023-06-09

8.5.6 Challenge


In section 8.1, we studied how to implement the __init__ method in a custom class. If the subclass has the same implementation as the superclass, you don’t need to override __init__ at all. But if you need customized initialization, as in the case of Supervisor, you want to override __init__. How can you override __init__ in the Supervisor class?

Hint Overriding __init__ isn’t different from overriding other methods. You use super() to create a proxy object to use the constructor of the superclass.